Remove loose wood knots or split wood pieces with a putty knife. Slide the putty knife along the rafters to remove wood splinters. Removing the wood chinks prior to sanding will help prevent damage to the sandpaper.
Fill knot holes, nail holes and splits with wood filler. Pack these voids to just above the wood surface. Smooth out the wood filler with a putty knife. Smoothing it out before it dries will reduce sanding time.
Sand the rafters with 60-grit sandpaper to even out the surface and remove any wood lumps. However, as this will likely leave sanding marks, even out the marks with 80-grit paper. Complete a final sanding with 120-grit sandpaper to smooth the surface even more. You could use an orbital sander to reduce the sanding time. Since you will be sanding above your head, wear safety goggles and a dust mask.
Wipe down the rafters with a damp cloth rag to remove any remaining dust and debris. Do not wet the rag, since water will cause the wood grain to rise.
Apply oil-based primer to the rafters to prevent raised wood grain. Paint on the primer with a small roller, or, to save time, tape up the area between the rafters with masking tape and newspaper, and spray the rafters with an electric spray gun. Apply three coats of primer, allowing one hour of drying time between coats. If spraying on the paint, spray on a tack coat of lightly misted paint. This coat need not be thick, nor does it need to fully cover the rafter. It is only in place to help the subsequent coats stick. Allow the tack coat to set for 15 minutes and apply two more full coats, allowing one hour of drying time between coats.